fix: return externalId in SCIM Groups responses#69
Merged
TerrifiedBug merged 1 commit intomainfrom Mar 8, 2026
Merged
Conversation
SCIM Groups endpoints never included externalId in responses. SCIM clients like pocket-id match remote resources by externalId during sync — without it, every group appears as an orphan (→ DELETE) and then as new (→ POST), causing a full teardown/rebuild cycle on every background sync. This destroyed team memberships and flooded audit logs. Also skip writing scim.group_adopted audit entries when POST re-encounters an existing group with no actual changes, reducing noise during normal sync cycles.
Contributor
Greptile SummaryThis PR fixes a root-cause SCIM sync issue where the Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as SCIM Client (pocket-id)
participant API as /Groups API
participant DB as PostgreSQL
Note over Client,DB: Before fix — every sync cycle
Client->>API: GET /Groups
API->>DB: SELECT scimGroups
DB-->>API: groups (no externalId)
API-->>Client: Resources[] — externalId missing
Client->>API: DELETE /Groups/{id} (orphan)
Client->>API: POST /Groups (re-create)
Note over Client,DB: After fix — incremental sync
Client->>API: GET /Groups
API->>DB: SELECT scimGroups
DB-->>API: groups (with externalId)
API-->>Client: Resources[] — externalId present
alt Group matched by externalId
Client->>API: PUT /Groups/{id} (update only if changed)
API-->>Client: 200 OK + externalId in response
else Truly new group
Client->>API: POST /Groups
API->>DB: INSERT scimGroup
API-->>Client: 201 Created + externalId
else Re-encounter existing group, no change
Client->>API: POST /Groups
API->>DB: findUnique (exists, externalId same)
API-->>Client: 200 OK (no audit log written)
end
Last reviewed commit: 7e55de3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/Groupsand/Groups/{id}) never includedexternalIdin responses. SCIM clients (pocket-id, Entra, Okta) match remote resources byexternalIdduring sync — without it, every group appears as an orphan (DELETE) and then as new (POST), causing a full teardown/rebuild on every background sync cyclegroup_mappingteam memberships and flooded audit logs withgroup_deleted/group_adopted/user_updatedentries on every syncscim.group_adoptedaudit entries when POST re-encounters an existing group with no actual changesRoot cause
Pocket-id's SCIM client does proper incremental sync:
GET /Groups→ match byexternalId→ PUT/POST/DELETE as needed. Our Users endpoint returnedexternalIdcorrectly, but Groups never did. This caused pocket-id to see all remote groups as unmatched orphans every sync cycle.Test plan